package com.example.zlw.dem19;

/**
 * @program: Zlw
 * @description:
 * @author: 诸葛龙辰
 * @create: 2022-11-08 20:16
 **/
public class Test {
    public static void main(String[] args) {
        Notebook huawei = NotebookFactory.createNotebook("Huawei");
        assert huawei != null;
        huawei.play();

        Notebook hasee = NotebookFactory.createNotebook("Hasee");
        assert hasee != null;
        hasee.play();
    }
}

abstract class Notebook {
    public abstract void play();
}

class Hasee extends Notebook {

    @Override
    public void play() {
        System.out.println("使用神舟笔记本");
    }
}

class Huawei extends Notebook {

    @Override
    public void play() {
        System.out.println("使用华为笔记本");
    }
}

class NotebookFactory {

    public static Notebook createNotebook(String type) {
        if ("Hasee".equals(type)) {
            return new Hasee();
        } else if ("Huawei".equals(type)) {
            return new Huawei();
        } else {
            return null;
        }
    }

}
